package org.kgc.alanhealth.service.impl;

import org.kgc.alanhealth.entity.*;
import org.kgc.alanhealth.mapper.*;
import org.kgc.alanhealth.service.MyInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MyinformationServiceImpl implements MyInformationService {
    @Autowired
    private HospitalUserMapper hospitalUserMapper;
    @Autowired
    private HospitalHealthmanageMapper hospitalHealthmanageMapper;
    @Autowired
    private HospitalAllergyMapper hospitalAllergyMapper;
    @Autowired
    private HospitalDiseaseMapper hospitalDiseaseMapper;
    @Autowired
    private HospitalUseraddressMapper hospitalUseraddressMapper;


    @Override
    public List<HospitalUser> getUserById(int id) {
        return hospitalUserMapper.selectUserById(id);
    }
    @Override
    public List<HospitalHealthmanage> getHealthManageById(int id) {return hospitalHealthmanageMapper.selectHealthById(id);}
    @Override
    public List<HospitalAllergy> selectAllergyById(int id) { return hospitalAllergyMapper.selectAllergyById(id);}
    @Override
    public List<HospitalDisease> selectAnamnesisById(int id){return hospitalDiseaseMapper.selectAnamnesisById(id);}
    @Override
    public List<HospitalAllergy> selectAllAllergy() { return hospitalAllergyMapper.selectAllAllergy(); }
    @Override
    public List<HospitalDisease> selectAllAnamnesis(){return hospitalDiseaseMapper.selectAllAnamnesis();}




    @Override
    public boolean addHealthManage(HospitalHealthmanage healthManage) {
        int result = hospitalHealthmanageMapper.addHealthManage(healthManage);
        return result > 0;
    }

    @Override
    public boolean updateHealthManage(HospitalHealthmanage healthInfo) {
        // 调用 Mapper 层的方法来更新健康信息
        int result = hospitalHealthmanageMapper.updateHealthManage(healthInfo);
        // 如果更新的行数大于0，则认为更新成功
        return result > 0;
    }

    @Override
    public boolean deleteHealthManage(int id) {
        // 调用 Mapper 层的方法来删除健康信息
        int result = hospitalHealthmanageMapper.deleteHealthManage(id);
        // 如果删除的行数大于0，则认为删除成功
        return result > 0;
    }

    @Override
    public List<HospitalUseraddress> getAddressById(int id)
    {
        return hospitalUseraddressMapper.selectAddressById(id);
    }
    @Override
    public boolean addAddress(HospitalUseraddress hospitalUseraddress) {
        int result = hospitalUseraddressMapper.addAddress(hospitalUseraddress);
        return result > 0;
    }
    @Override
    public boolean updateAddress(HospitalUseraddress hospitalUseraddress) {
        // 调用 Mapper 层的方法来更新健康信息
        int result = hospitalUseraddressMapper.updateAddress(hospitalUseraddress);
        // 如果更新的行数大于0，则认为更新成功
        return result > 0;
    }
    @Override
    public boolean deleteAddressManage(int id) {
        // 调用 Mapper 层的方法来删除健康信息
        int result = hospitalUseraddressMapper.deleteAddressManage(id);
        // 如果删除的行数大于0，则认为删除成功
        return result > 0;
    }

    @Override
    public List<HospitalHealthmanage> getHealthManageByCard(String idcard) {
        return hospitalHealthmanageMapper.selectHealthManageByCard(idcard);
    }

}
